<template>
	<view class="container">
		<view class="header">
			<view class="mb-30" style="text-indent: 24px;">文章来至【小镜界】微信订阅号，可以关注订阅号，查看更多好文！</view>
			<!-- <view class="value">{{noRead}}</view> -->
		</view>
		<view class="flex-fill overflow-hidden">
			<view class="content" v-if="!boardcast.length">
				<view class="top">小镜界好文列表</view>
				<view class="flex-fill d-flex align-items-center just-content-center">
					暂无最新消息
				</view>
			</view>
			<scroll-view class="content" scroll-y v-else>
				<view class="top">小镜界好文列表</view>
				<list-cell v-for="(score, index) in boardcast" :key="index">
					<view class="score" @click="toWxActicale(score.BrdcRedirectContent)">
						<image class="img" :src="score.BrdcCoverPic"></image>
						<view class="left">
							<view class="title mb-10">{{score.BrdcTitle }}</view>
							<view class="mb-10">{{ score.BrdcSubtitle }}</view>
							<view>{{ score.CreateDate }}</view>
						</view>
						<view class="right" v-if="score.BrdcDelFlag!=1">•</view>
					</view>
				</list-cell>
				<nomore :visible="!loading" :line="false" text="没有更多新消息~"></nomore>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import listCell from '@/components/list-cell/list-cell.vue'
	import nomore from '@/components/nomore/nomore.vue'

	export default {
		components: {
			listCell,
			nomore
		},
		computed: {
			title() {
				return (score) => {
				}
			}
		},
		data() {
			return {
				boardcast:0,
				noRead:[],
				loading: false
			}
		},
		async onLoad(options) {
			this.loading = true
			await this.getBoardcast();
			this.loading = false
		},
		methods: {
			toWxActicale(url) {
				//打开微信公众号文章
				//wx.miniProgram.navigateTo({url: url})
				uni.navigateTo({
					url: `/pages/my/components/webView/webView?url=${url}`
				})
			},
			//获取 播报数据
			getBoardcast() {
				let that = this;
				let cateOp = {
					url: "api/Lx_Self_Boardcast/UI_GetPageData",
					data: {
						page:1,
						rows:20
					}
				}

				this.$request.Post(cateOp, (ret) => {
					if (ret.rows.length > 0) {
						that.boardcast = ret.rows;
						that.boardcast.map(n => {
							n.BrdcCoverPic = that.$request.setImgUrl(n.BrdcCoverPic);
							return n;
						});
					}
				});
			},
			//获取数据
			updateIsRead(item) {
				let that = this;
				item.NoticeIsRead=1;
				item.NoticeIsReadDate=new Date();
				let cateOp = {
					url: "api/Lx_Self_Notice/UI_Update",
					data: {
						mainData: item, 
						detailData: null,
						delKeys: null
					}
				}
			
				this.$request.Post(cateOp, (ret) => {
					if (ret.code=="311") {
						let noReadList=this.scores.filter(e=>{
							return e.NoticeIsRead!=1
						});
						this.noRead=noReadList.length;
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
	}

	.container {
		width: 100%;
		display: flex;
		flex-direction: column;
	}

	.header {
		margin-bottom: 20rpx;
		background-color: $bg-color-white;
		width: 100%;
		flex-shrink: 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 30rpx 40rpx;
		font-size: $font-size-medium;
		color: $text-color-base;

		.value {
			font-size: 64rpx;
			color: $color-primary;
			font-weight: 500;
			margin-bottom: 30rpx;
		}

		.rules {
			width: 100%;
			display: flex;
			justify-content: flex-end;
			align-items: center;

			.rules-icon {
				width: 32rpx;
				height: 32rpx;
				margin-right: 10rpx;
			}
		}
	}

	.content {
		width: 100%;
		height: 100%;
		background-color: $bg-color-white;
		display: flex;
		flex-direction: column;

		.top {
			padding: 20rpx 30rpx;
			font-size: $font-size-lg;
			font-weight: 500;
		}

		.score {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			
			.img{
				width:140rpx ;
				height: 140rpx;
				border-radius: 50%;
			}

			.left {
				flex: 1;
				display: flex;
				flex-direction: column;
				font-size: $font-size-sm;
				color: $text-color-assist;
				padding-left: 20rpx;

				.title {
					font-size: $font-size-lg;
					color: $text-color-base;
					margin-bottom: 10rpx;
				}
			}

			.right {
				font-size: $font-size-lg;
				color: $color-primary;
			}
		}
	}
</style>
